package com.example.bakend.mapper;

import com.example.bakend.pojo.Record;
import com.example.bakend.pojo.RecordVoReaderVoBook;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface RecordMapper {
    @Insert("insert into borrow_records (reader_id,book_id,borrow_date,return_date,num) values (#{readerId},#{bookId},#{borrowDate},#{returnDate},#{num})")
    Integer insertRecord(Record record);

    @Select("select * from borrow_records where id = #{id}")
    Record selectRecord(Integer id);

    //    展示所有数据
//    @Select("select * from borrow_records")
//    List<Record> selectRecords();

    // TODO: 2024/7/18  借阅记录条件查询  不传条件是全部拿到
    List<RecordVoReaderVoBook> getRecords(@Param("readerId") Integer readerId,
                                          @Param("bookId") Integer bookId,
                                          @Param("borrowDateBegin") LocalDateTime borrowDateBegin,
                                          @Param("borrowDateEnd") LocalDateTime borrowDateEnd);

    Integer deleteRecord(@Param("ids") List<Integer> ids);

    @Select("select * from borrow_records where book_id = #{BookId}")
    List<Record> selectBookIdRecord(Integer BookId);

//    还书
    Integer getRestore(Integer id);
}
